#include "tvoeradio.h"

#ifdef Q_WS_MAC

static OSStatus appleEventProcessor(const AppleEvent *ae, AppleEvent *event, long handlerRefCon)
{
    TvoeRadio *app = (TvoeRadio *) handlerRefCon;

    OSType aeID = typeWildCard;
    OSType aeClass = typeWildCard;

    AEGetAttributePtr(ae, keyEventClassAttr, typeType, 0, &aeClass, sizeof(aeClass), 0);
    AEGetAttributePtr(ae, keyEventIDAttr, typeType, 0, &aeID, sizeof(aeID), 0);

    if (aeClass == kCoreEventClass) {
        if (aeID == kAEReopenApplication) {
            app->m_mainWindow.showHide();
            app->m_mainWindow.activateWindow();
        }
        return noErr;
    }

    return eventNotHandledErr;
}

void TvoeRadio::constructOp()
{
    m_appleEventProcessorUPP = AEEventHandlerUPP(appleEventProcessor);
    AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, m_appleEventProcessorUPP, (long) this, true);
}

void TvoeRadio::destructOp()
{
}

#endif

